package com.liuf.es.controller;

import com.liuf.es.domain.Article;
import com.liuf.es.service.IArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Optional;

/**
 * @author LIUFANG
 */
@RestController
@RequestMapping(value = "/api/es")
public class ArticleController {

    @Autowired
    private IArticleService articleServiceImpl;

    @PostMapping(value = "/save")
    public Article save(@RequestBody Article article){

        return articleServiceImpl.save(article);
    }

    @GetMapping(value = "/{id}")
    public Optional<Article> getByID(@PathVariable Long id){

        return articleServiceImpl.getByID(id);
    }

    @GetMapping(value = "/query")
    public Page<Article> queryAll(@RequestParam Article article){

        return articleServiceImpl.queryAll(article);
    }

}
